package wnhz.com.business.freeshop.activity.fristfree;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.journeyapps.barcodescanner.CaptureActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wnhz.com.business.R;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.view.TranslucentActionBarW;


/**
 * 二维码扫描
 */
public class ScanningAvtivity extends MyBaseActivity implements ActionBarClickListener {

    @BindView(R.id.actionbar)
    TranslucentActionBarW actionbar;
    @BindView(R.id.ll_scanning)
    LinearLayout llScanning;

    private int REQUEST_CODE = 1;

    public static Intent createIntent(Context context) {
        Intent intent = new Intent(context, ScanningAvtivity.class);
        return intent;
    }


    @Override
    protected void handleMsg(Message msg) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scanning_avtivity);
        ButterKnife.bind(this);

        actionbar.setData("商品核销", R.drawable.ic_left_back, null, 0, null, 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //改变状态栏颜色
            this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }
    }

    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }

    @OnClick(R.id.ll_scanning)
    public void onViewClicked() {
        //调用zxing(屏幕旋转了90度，待解决)
        Intent intent = new Intent(ScanningAvtivity.this, CaptureActivity.class);
        startActivityForResult(intent, REQUEST_CODE);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case 1:

                    break;
            }
        }
    }
}
